var userInfo;
Jes.extend({
	getUserSess : function(type){
		Jes.sync(function(){Jes.action("getUserSess",false,function(data){userInfo = data;});});
		if(!userInfo){
			if(type == 1) alert("Session过期，请重新登入！"),parent.Jes.url("../../jesacl/html/login.html");
			else Jes.url("../config/error.html");
			return false;
		}else{
			return true;
		}
	}
	,isFlowAdmin : function(){
		return userInfo.roles.indexOf('flowadmin')!=-1;
	}
});

//__________________________________________________附件通用代码begin________________________________________________________//

JesAttach = {
	/**
	* @todo：清除session附件
	* @date：2008-7-28 11:19
	* @author：hyh
	*/
	clearAttach : function(){
		Jes.action("removeSessAttr","ATTACH_LIST");
	}
	/**
	* @todo：删除上传附件
	* @date：2008-7-28 16:54
	* @author：hyh
	*/
	,delAttachRow : function(td,id,attachname){
		DWRUtil.useLoadingMessage("正在读取数据...");
		var info = "你确定要删除上传附件吗？";
		if(id != "") info = "你确定附件在数据库删除吗？";
		if(confirm(info)){
			var row = td.parentElement.parentElement;
			var tb = td.parentElement.parentElement.parentElement.parentElement;
		    tb.deleteRow(row.rowIndex);
		    Jes.action("deleteAttach",id,attachname);
		}
	}
}
//__________________________________________________附件通用代码end__________________________________________________________//
//所有下拉框
Jes.Select={
	oppor_dic : function(){
		this._dic("optype",{"keytype":"OPTYPE"});//商机类型
		this._dic("bussoptype",{"keytype":"BUSSOPTYPE"});//商机业务类型
		this._dic("oppro",{"keytype":"OPPRO"});//商机属性
		this._dic("area",{"keytype":"AREA"});//商机区域
	}
	,oppor_query_dic : function(){
		this._dic("optype",{"keytype":"OPTYPE"});//商机类型
		this._dic("flownode",{"keytype":"FLOWNODE"});//商机类型
		this._dic("status",{"keytype":"OPSTATUS"});//商机状态
	}
	,_dic : function(el,param){//此方法名需要优化
		Jes.sel(el,"acldic_query_sql@sel",param);//如果el不存在,不会显示下拉框
	}
	,remove : function(elName,value,isChooseAll){
		if(!$(elName)) return;
		if(!Jes.isNull(value)){
			var el = $(elName),_vs = value.split(",");
			for(var i=0;i<_vs.length;i++){
				for(var j=0;j<el.length;j++){
					if(_vs[i] == el[j].value){
						el.remove(j);
						break;
					}
				}
			}
		}else{
			DWRUtil.removeAllOptions(elName);
			if(isChooseAll || isChooseAll == undefined){
				DWRUtil.addOptions(elName,[{ name:'--------------------------', id:''}],"id","name");
			}
		}
	}
}